package com.justonetech.translation.manager;

import com.justonetech.translation.daoservice.BillDetailService;
import com.justonetech.translation.daoservice.BillService;
import com.justonetech.translation.domain.Bill;
import com.justonetech.translation.domain.BillDetail;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * Created with IntelliJ IDEA.
 * User: dell
 * Date: 12-7-11
 * Time: 下午1:45
 * To change this template use File | Settings | File Templates.
 */
@Service
public class BillManager {
    @Autowired
    private BillService billService;

    @Autowired
    private BillDetailService billDetailService;

    public void delete(Long id) {
        Bill bill = billService.get(id);

        for(BillDetail detail : bill.getBillDetails()) {
            billDetailService.delete(detail);
        }

        billService.delete(bill);
    }
}
